package com.example.administrator.xinyutg.fragment;


import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;

import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.Toast;

import com.example.administrator.xinyutg.R;
import com.example.administrator.xinyutg.costants.Path;

/**
 * A simple {@link Fragment} subclass.
 */
public class MoreFragment extends Fragment implements View.OnClickListener{

    private TextView tvClear;
    private TextView tvPhone;
    private TextView tvTeam;
    private TextView tvUrl;
    private TextView tvBlog;


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View v = inflater.inflate(R.layout.fragment_more, container, false);
        initView(v);

        return v;
    }

    private void initView(View v) {
        tvClear = (TextView) v.findViewById(R.id.tv_more_clear);
        tvPhone = (TextView) v.findViewById(R.id.tv_more_phone);
        tvTeam = (TextView) v.findViewById(R.id.tv_more_team);
        tvUrl = (TextView) v.findViewById(R.id.tv_more_url);
        tvBlog = (TextView) v.findViewById(R.id.tv_more_blog);

        tvClear.setOnClickListener(this);
        tvPhone.setOnClickListener(this);
        tvTeam.setOnClickListener(this);
        tvUrl.setOnClickListener(this);
        tvBlog.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {

        switch (v.getId()){
            case R.id.tv_more_clear:
                Toast.makeText(getActivity(),"清除缓存完成",Toast.LENGTH_SHORT).show();
                break;
            case R.id.tv_more_phone:
                Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + Path.PHONE_NUM));
                startActivity(intent);
                break;
            case R.id.tv_more_team:
                Intent intent1 = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + Path.PHONE_NUM));
                startActivity(intent1);
                break;
            case R.id.tv_more_url:
                Intent intent2=new Intent();
                intent2.setData(Uri.parse(Path.URL));
                intent2.setAction(Intent.ACTION_VIEW);
                startActivity(intent2);
                break;
            case R.id.tv_more_blog:
                Intent intent3=new Intent();
                intent3.setData(Uri.parse(Path.BLOG));
                intent3.setAction(Intent.ACTION_VIEW);
                startActivity(intent3);
                break;
        }
    }
}
